package system;

import client.CmdHandler;
import client.VehicleSimulator;
import device.Odometer;
import factory.DisplayAbstractFactory;
import interfaces.IDisplayGaugeGui;
import interfaces.IOdometer;
import interfaces.IGaugeClient;
import interfaces.IDisplayObserver;
import it.unibo.baseEnv.basicFrame.EnvFrame;
import it.unibo.is.interfaces.IBasicEnvAwt;

/**
 * @author Stefano&Davide
 * @version 1.0
 */

public class Odometer2012Main {
	
	protected IOdometer ckm = null;
	protected IDisplayGaugeGui ckmDisplay = null;
	protected IBasicEnvAwt env = null;
	protected IGaugeClient vehicle;
	protected IDisplayObserver ckmObserver1;
	
	public Odometer2012Main(){ }
	
	protected void configureTheSystem(){
		env =new EnvFrame("ContaKm2012");
		env.init();
		DisplayAbstractFactory factoryDisplay=DisplayAbstractFactory.getInstance(DisplayAbstractFactory.guiOdometer);
		ckmDisplay=(IDisplayGaugeGui)factoryDisplay.makeDisplay(env);	
		ckm=new Odometer(ckmDisplay);
		CmdHandler handler=new CmdHandler(env.getOutputView(), ckm);
		ckmDisplay.setHandler(handler);
		vehicle=new VehicleSimulator(env);
	}
	
	public void doJob(){
		try {
			vehicle.startToRun(ckm);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) throws Exception{
		Odometer2012Main program=new Odometer2012Main();
		program.configureTheSystem();
		program.doJob();
	}
	
}